package com.haozhen.kudu.sink;

import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import javax.xml.crypto.Data;
import java.time.temporal.ValueRange;
import java.util.HashMap;
import java.util.Map;

/**
 * @author haozhen
 * @email haozh@ync1.com
 * @date 2021/4/17  18:32
 */
public class FlinkToKuduDemo {
    public static void main(String[] args) {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        DataStreamSource<UserInfo> userInfoDataStreamSource = env.fromElements(
                new UserInfo("001", "Jack", 18),
                new UserInfo("002", "Rose", 20),
                new UserInfo("003", "Cris", 22),
                new UserInfo("004", "Lily", 19),
                new UserInfo("005", "Lucy", 21),
                new UserInfo("006", "Json", 24),
                new UserInfo("007", "haozhen", 29)
        );

        SingleOutputStreamOperator<Map<String, Object>> map = userInfoDataStreamSource.map(new MapFunction<UserInfo, Map<String, Object>>() {
            @Override
            public Map<String, Object> map(UserInfo userInfo) throws Exception {
                Map<String, Object> result = new HashMap<>();
                result.put("id", userInfo.getId());
                result.put("name", userInfo.getName());
                result.put("age", userInfo.getAge());
                return result;
            }
        });

        String masterAddr="";
        String tableName = "";

    }
}
